<?php

App::uses('AppModel', 'Model');

class LeaveTypeRule extends AppModel {
    
    public $belongsTo = array('LeaveType');
    
    /**
     * refactor data after find
     * @param  array  $collection
     * @param  string $primary
     * @return array
     */
    public function afterFind($collection=array(), $primary=false) {
        foreach ($collection as &$row) {
            if (! empty($row['LeaveTypeRule']['arguments'])) {
                $row['LeaveTypeRule']['arguments'] = json_decode($row['LeaveTypeRule']['arguments'], true);
            }
        }
        
        return $collection;
    }
    
}